<?php

namespace app\api\controller;

use tools\Http;

/**
 * 登录管理
 * Class Configs
 * @package app\admin\controller
 */
class Login extends Base
{

    //发送短信
    public function sendMsg(){
        $data = input("");
        $msg = $this->checkData($data,[
            ["mobile", "require|regex:/^1[0-9]{1}\d{9}$/", "手机号码输入有误"],
            ["ip", "require|ip", "ip地址有误"],
        ]);
        //验证规则是否通过
        if($msg === true){
            $ImgApiData = config("ImgApiData");//获取接口配置
            $Http = new Http();
            $Http->setUrl($ImgApiData["domain"]."/".$ImgApiData["ApiList"]["sendSms"]);
            $Http->setData([
                'token'     => md5(md5($ImgApiData["key"]).date("Y-m-d")),
                'mobile'    => $data["mobile"],
                'ip'        => $data["ip"],
            ]);
            $result = $Http->sendRequest();
        }else{
            $this->error_return["msgError"]["msg"] = $msg;//验证不通过添加错误
            $result = $this->error_return["msgError"];
        }
        return json($result);
    }

}
